//
//  TestUIButtonViewController.m
//  iOSDeme
//
//  Created by wxf on 2024/8/25.
//

#import "TestUIButtonViewController.h"

@interface TestUIButtonViewController ()

@end

@implementation TestUIButtonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    NSLog(@"TestUILabelViewController viewDidLoad");
    self.view.backgroundColor = [UIColor whiteColor];
    [self mainTest];
}

- (void)mainTest{
    //实例化UIButton
    UIButton * button = [[UIButton alloc] initWithFrame:CGRectMake(10, 100, 100, 40)];
    button.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:button];
    
    //创建系统的Button
    UIButton * button1 = [UIButton buttonWithType:UIButtonTypeSystem];
    button1.frame = CGRectMake(10, 150, 100, 40);
    button1.backgroundColor = [UIColor cyanColor];
    
    [button1 setTitle:@"我是按钮" forState:UIControlStateNormal];
    [button1 setTitle:@"我是按钮(高亮)" forState:UIControlStateHighlighted];
    [self.view addSubview:button1];
    
    //创建系统的Button
    UIButton * button2 = [UIButton buttonWithType:UIButtonTypeSystem];
    button2.frame = CGRectMake(10, 200, 100, 40);
    button2.backgroundColor = [UIColor cyanColor];
    
    [button2 setTitle:@"我是按钮" forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    [self.view addSubview:button2];
    
    //创建系统的Button
    UIButton * button3 = [UIButton buttonWithType:UIButtonTypeSystem];
    button3.frame = CGRectMake(10, 250, 100, 40);
    button3.backgroundColor = [UIColor cyanColor];
    
    [button3 setTitle:@"我是按钮" forState:UIControlStateNormal];
    [button3 setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];
    button3.titleLabel.font = [UIFont boldSystemFontOfSize:20];
    [self.view addSubview:button3];
    
    
    //添加点击事件
    UIButton * button4 = [UIButton buttonWithType:UIButtonTypeSystem];
    button4.frame = CGRectMake(10, 250, 100, 40);
    button4.backgroundColor = [UIColor cyanColor];
    
    [button4 setTitle:@"我是按钮4" forState:UIControlStateNormal];
    [button4 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    
    [button4 addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button4];
    
    NSLog(@"测试UIButton");
}

-(void) buttonClicked{
    NSLog(@"点击事件");
    //随机颜色
    self.view.backgroundColor = [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1.0];
}

@end
